﻿package {
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
    import flash.events.*;

	
	/**
	 * Main
	 */
	public class Main extends Sprite {
		private var clock_skin:clockskin;
		private var timer:Timer;
		private var bg:Sprite;
		
		public function Main():void {
				init();
		}

		private function init(Size_W:Number = 550,Size_H:Number = 400):void
		{
			// set stage property
			this.stage.align = StageAlign.TOP_LEFT;
			this.stage.scaleMode = StageScaleMode.NO_SCALE;
			this.stage.frameRate=24;
			this.stage.stageWidth = 550;
			this.stage.stageHeight = 400;
			bg = new Sprite();
			bg.graphics.beginFill(0x222222);
			bg.graphics.drawRect(0,0,550,400);
			bg.graphics.endFill();
			addChild(bg);

			clock_skin = new clockskin(Math.max(20, Size_W),Math.max(20, Size_H));
			clock_skin.init();
			addChild(clock_skin);
			
            clock_skin.getTime();  //first get time
			
			//Update the clock time
        	timer = new Timer(1000); 
            timer.addEventListener(TimerEvent.TIMER, onTick);
            timer.start();
		}
		
        private function onTick(evt:TimerEvent):void 
        {
        	// Updates the clock display.
            clock_skin.getTime();
        }		
	
	}
}